home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C ++ / Applications / TimGA 1.2.1 / .cp / CGraphGAApp.cp < prev    next >
Encoding:
Text File  |  1997-07-16  |  19.0 KB  |  755 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. //    CGraphGAApp.cp        ©1995-97 Timo Eloranta        All rights reserved.
  3. // ===========================================================================
  4. //    The application class - subclassed from LDocApplication.
  5.  
  6. #include <StandardFile.h>
  7.  
  8. // -- Core classes
  9. #include <LApplication.h>
  10. #include <LCaption.h>
  11. #include <LClipboard.h>
  12. #include <LGroupBox.h>
  13. #include <LGrowZone.h>
  14. #include <LWindow.h>
  15. #include <LPicture.h>
  16. #include <LRadioGroup.h>
  17. #include <LString.h>
  18. #include <LTabGroup.h>
  19.  
  20. // -- Utilities
  21. #include <UMemoryMgr.h>
  22. #include <UModalDialogs.h>
  23. #include <UDrawingState.h>
  24. #include <URegistrar.h>
  25. #include <UDesktop.h>
  26. #include <UWindows.h>
  27.  
  28. // -- Grayscale Appearance
  29. #include <UGALibRegistry.h>        
  30. #include <LGABox.h>
  31. #include <LGAEditField.h>
  32. #include <LGAPushButton.h>
  33. #include <LGARadioButton.h>
  34. #include <LGACheckbox.h>
  35. #include <LGAPrimaryBox.h>
  36. #include <LGAPrimaryGroup.h>
  37. #include <LGASeparator.h>
  38. #include <LGADialogBox.h>
  39.  
  40. #include <PP_Messages.h>
  41. #include <PP_Resources.h>
  42.  
  43. #include <profiler.h>        // Profiler
  44.  
  45. #include "CGraphGAApp.h"
  46. #include "CGraphGADoc.h"
  47. #include "CGraphWindow.h"
  48. #include "CGraphPane.h"
  49. #include "CFitness.h"
  50.  
  51. #include "CProbDialog.h"
  52. #include "CSelectionDialog.h"
  53. #include "CTerminationDialog.h"
  54. #include "CGeneralDialog.h"
  55. #include "CEvalDialog.h"
  56.  
  57. #include "CMyCaption.h"
  58. #include "MyUtils.h"        // FastRandom
  59.  
  60. #include "CAGASlider.h"        // James Jennings' grayscale slider class
  61.  
  62. #include "GraphGA_PaneIDs.h"
  63.  
  64.  
  65. // ===========================================================================
  66. //        • Main Program
  67. // ===========================================================================
  68.  
  69. void
  70. main( void )
  71. {
  72. #if __profile__
  73.     if (! ProfilerInit( collectDetailed, bestTimeBase, 130, 12 )) {
  74.         ProfilerSetStatus( false );
  75. #endif
  76.                                         
  77.     #ifdef Debug_Throw                        // Set Debugging options
  78.         gDebugThrow = debugAction_Alert;    
  79.     #endif
  80.     #ifdef Debug_Signal
  81.         gDebugSignal = debugAction_Alert;
  82.     #endif
  83.     
  84.         InitializeHeap(3);
  85.         UQDGlobals::InitializeToolbox( &qd );
  86.         
  87.         FastRandom(0);            // Initialize the randomizer
  88.         
  89.         new LGrowZone(20000);
  90.     
  91.         CGraphGAApp    theApp;        // Create an instance of our app class...
  92.         theApp.Run();            // ...and run it.
  93.  
  94. #if __profile__
  95.         ProfilerDump("\pTimGA.prof");
  96.         ProfilerTerm();
  97.     }
  98. #endif
  99. }
  100.  
  101. // ---------------------------------------------------------------------------
  102. //        • CGraphGAApp
  103. //
  104. //          Called by:    main
  105. // ---------------------------------------------------------------------------
  106. //    Constructor
  107.  
  108. CGraphGAApp::CGraphGAApp()
  109. {
  110.     SetDefaults();
  111.     RegisterClasses();
  112.     
  113.     AddAttachment(new LClipboard);    // Create and attach a clipboard object
  114. }
  115.  
  116. // ---------------------------------------------------------------------------
  117. //        • Initialize
  118. //
  119. //          Called by:    LApplication::Run
  120. // ---------------------------------------------------------------------------
  121.  
  122. void
  123. CGraphGAApp::Initialize()
  124. {
  125.     SetDocToBeShot( false );
  126.  
  127.     mWindow = (CGraphWindow*)                                     // Create
  128.         CGraphWindow::CreateWindow( WIND_GraphGADoc, this );    // main window
  129.  
  130.     ThrowIfNil_( mWindow );
  131.     InitForNoGraph();
  132.  
  133.     mWindow -> Show();
  134. }
  135.  
  136. // ---------------------------------------------------------------------------
  137. //        • InitForNoGraph    (PRIVATE)
  138. //
  139. //          Called by:    CGraphGAApp::CGraphGAApp
  140. //                        CGraphGAApp::RemoveDoc
  141. // ---------------------------------------------------------------------------
  142.  
  143. void
  144. CGraphGAApp::InitForNoGraph()
  145. {
  146.     CGraphPane *theGraphPane = mWindow -> GetGraphPane();
  147.  
  148.     mWindow -> SetDescriptor( "\pTimGA" );
  149.     
  150.     mWindow -> UpdateGraphInfo( );
  151.     mWindow -> UpdatePopInfo( true );
  152.     mWindow -> UpdateIterStateInfo( );
  153.     mWindow -> UpdateBestInfo( true );
  154.     
  155.     theGraphPane -> SetGraph( nil );
  156.     theGraphPane -> Refresh();
  157.  
  158.     mDoc = nil;
  159.     
  160.     SwitchTarget( theGraphPane );
  161. }
  162.  
  163. // ---------------------------------------------------------------------------
  164. //        • ~CGraphGAApp
  165. // ---------------------------------------------------------------------------
  166. //    Destructor.
  167.  
  168. CGraphGAApp::~CGraphGAApp()
  169. {
  170.     if ( mDoc )
  171.         RemoveDoc();
  172.  
  173.     if ( mWindow )
  174.         delete mWindow;
  175. }
  176.  
  177. // ---------------------------------------------------------------------------
  178. //        • RemoveDoc        (PRIVATE)
  179. //
  180. //          Called by:    CGraphGAApp::~CGraphGAApp
  181. //                        CGraphGAApp::ObeyCommand
  182. //                        CGraphGAApp::OpenDocument
  183. //                        CGraphGAApp::MakeNewDocument
  184. // ---------------------------------------------------------------------------
  185.  
  186. void
  187. CGraphGAApp::RemoveDoc()
  188. {
  189.     if (! mDoc ) {
  190.         SysBeep(1);        // This should *never* happen
  191.     } else {
  192.         if ( mWindow )
  193.             mWindow -> ResetSuperCommanderToApp();
  194.         
  195.         delete mDoc;
  196.         
  197.         InitForNoGraph();
  198.     }
  199. }
  200.  
  201. // ---------------------------------------------------------------------------
  202. //        • ObeyCommand
  203. //
  204. //          Called by:    LCommander::ProcessCommand
  205. // ---------------------------------------------------------------------------
  206. //    Respond to commands
  207.  
  208. Boolean
  209. CGraphGAApp::ObeyCommand(
  210.     CommandT    inCommand,
  211.     void        *ioParam)
  212. {
  213.     Boolean        cmdHandled = true;
  214.  
  215.     switch (inCommand) {
  216.     
  217.         case cmd_New:
  218.             if ( AskNewGraphSize() )
  219.                 cmdHandled = LDocApplication::ObeyCommand( cmd_New, ioParam );
  220.             break;
  221.  
  222.         case cmd_CloseGraph:
  223.             if ( mDoc )
  224.                 RemoveDoc();
  225.             break;
  226.             
  227.         case cmd_Quit:
  228.             if ( mDoc )
  229.                 RemoveDoc();
  230.             cmdHandled = LDocApplication::ObeyCommand( cmd_Quit, ioParam );
  231.             break;
  232.  
  233.         case cmd_General:
  234.             CGeneralDialog *theGDialog = 
  235.                 (CGeneralDialog *) LWindow::CreateWindow( WIND_General, this);
  236.                 
  237.             theGDialog -> InitDialog();
  238.             theGDialog -> SetValues( mGeneral );
  239.  
  240.             theGDialog -> Show();
  241.             break;
  242.  
  243.         case cmd_SetGeneral:
  244.             SetGeneralFromDialog( (SLGADialogResponse *) ioParam, 0 );
  245.  
  246.             mWindow -> UpdateGraphInfo( );
  247.             mWindow -> UpdatePopInfo( true );
  248.  
  249.             (mWindow -> GetGraphPane()) -> SetGraph( nil );
  250.             (mWindow -> GetGraphPane()) -> Refresh();
  251.             break;
  252.  
  253.         case cmd_Selection:
  254.             CSelectionDialog *theSDialog = 
  255.                 (CSelectionDialog *) LWindow::CreateWindow( WIND_Select, this);
  256.                 
  257.             theSDialog -> InitDialog();
  258.             theSDialog -> SetValues( mSelection, mGeneral.sizePop );
  259.             theSDialog -> Show();
  260.             break;
  261.  
  262.         case cmd_SetSelection:
  263.             SetSelFromDialog( (SLGADialogResponse *) ioParam);
  264.             break;
  265.             
  266.         case cmd_Recombination:
  267.             CProbDialog *thePDialog = 
  268.                 (CProbDialog *) LWindow::CreateWindow( WIND_Prob, this);
  269.                 
  270.             thePDialog -> InitDialog();
  271.             thePDialog -> SetValues( mCrossoverProb, mMutationProb );
  272.             thePDialog -> Show();
  273.             break;
  274.             
  275.         case cmd_SetProbabilities:
  276.             SetProbsFromDialog( (SLGADialogResponse *) ioParam);
  277.             if ( mDoc )
  278.                 mDoc -> SetPopProbabilities( mCrossoverProb, mMutationProb );
  279.             break;
  280.  
  281.         case cmd_Termination:
  282.             CTerminationDialog *theTDialog = 
  283.                 (CTerminationDialog *) LWindow::CreateWindow( WIND_Terminate, this);
  284.                 
  285.             theTDialog -> InitDialog();
  286.             theTDialog -> SetValues( mTermination );
  287.             theTDialog -> Show();
  288.             break;
  289.  
  290.         case cmd_SetTermination:
  291.             SetTerFromDialog( (SLGADialogResponse *) ioParam);
  292.             if ( mDoc )
  293.                 mDoc -> SetPopTermination( mTermination );
  294.             break;
  295.  
  296.         case cmd_Evaluation:
  297.             CEvalDialog *theEDialog = 
  298.                 (CEvalDialog *) LWindow::CreateWindow( WIND_Evaluate, this);
  299.                 
  300.             theEDialog -> InitDialog();
  301.             theEDialog -> SetValues( mEvaluation );
  302.             theEDialog -> Show();
  303.             break;
  304.  
  305.         case cmd_SetEvaluation:
  306.             SetEvalFromDialog( (SLGADialogResponse *) ioParam);
  307.             break;
  308.             
  309.         default:
  310.             cmdHandled = LDocApplication::ObeyCommand(inCommand, ioParam);
  311.             break;
  312.     }
  313.     
  314.     return cmdHandled;
  315. }
  316.  
  317. // ---------------------------------------------------------------------------
  318. //        • FindCommandStatus
  319. //
  320. //          Called by:    LCommander::ProcessCommandStatus
  321. // ---------------------------------------------------------------------------
  322. //    Pass back whether a Command is enabled and/or marked (in a Menu)
  323.  
  324. void
  325. CGraphGAApp::FindCommandStatus(
  326.     CommandT    inCommand,
  327.     Boolean        &outEnabled,
  328.     Boolean        &outUsesMark,
  329.     Char16        &outMark,
  330.     Str255        outName)
  331. {
  332.     outUsesMark = false;
  333.  
  334.     switch (inCommand) {
  335.  
  336.         case cmd_CloseGraph:
  337.             outEnabled = false;        // See CGraphGADoc::FindCommandStatus !!
  338.             break;
  339.  
  340.         case cmd_Open:
  341.         case cmd_New:
  342.         case cmd_General:
  343.         case cmd_Selection:
  344.         case cmd_Recombination:
  345.         case cmd_Termination:
  346.         case cmd_Evaluation:
  347.             outEnabled = true;
  348.             break;
  349.  
  350.         default:
  351.             LDocApplication::FindCommandStatus(inCommand, outEnabled,
  352.                                             outUsesMark, outMark, outName);
  353.             break;
  354.     }
  355. }
  356.  
  357. // ---------------------------------------------------------------------------
  358. //        • ShowAboutBox
  359. //
  360. //          Called by:    LApplication::ObeyCommand
  361. // ---------------------------------------------------------------------------
  362.  
  363. void
  364. CGraphGAApp::ShowAboutBox()
  365. {
  366.     StDialogHandler        theHandler( WIND_NewAbout, this);
  367.     LWindow                *theDialog = theHandler.GetDialog();
  368.  
  369.     if ( theDialog ) {
  370.         while ( true ) {
  371.             MessageT    hitMessage = theHandler.DoDialog();
  372.             
  373.             if ( hitMessage == msg_OK )
  374.                 break;
  375.         }
  376.     } else {
  377.         UDesktop::Deactivate();
  378.         ::Alert(ALRT_About, nil);
  379.         UDesktop::Activate();
  380.     }
  381. }
  382.  
  383. // ---------------------------------------------------------------------------
  384. //        • OpenDocument
  385. //
  386. //          Called by:    CGraphGAApp::ChooseDocument
  387. //                        LDocApplication::SendAEOpenDoc
  388. //                        LDocApplication::DoAEOpenOrPrintDoc
  389. // ---------------------------------------------------------------------------
  390. //    Create a new graph "document" from a graph file
  391.  
  392. void
  393. CGraphGAApp::OpenDocument(
  394.     FSSpec    *inMacFSSpec)
  395. {
  396.     if ( mDoc )
  397.         RemoveDoc();
  398.  
  399.     mDoc = new CGraphGADoc( this, inMacFSSpec);
  400.     
  401.     if ( mDocShouldGetShot ) {
  402.         RemoveDoc();
  403.         SetDocToBeShot( false );
  404.     } else
  405.         SwitchTarget( mWindow -> GetGraphPane() );
  406. }
  407.  
  408. // ---------------------------------------------------------------------------
  409. //        • MakeNewDocument
  410. //
  411. //          Called by:    LDocApplication::SendAECreateDocument
  412. //                        LDocApplication::HandleCreateElementEvent
  413. // ---------------------------------------------------------------------------
  414. //    Create a new Document with RANDOM graph...
  415.  
  416. LModelObject*
  417. CGraphGAApp::MakeNewDocument()
  418. {
  419.     if ( mDoc )
  420.         RemoveDoc();
  421.  
  422.     mDoc = new CGraphGADoc( this, nil);
  423.     
  424.     SwitchTarget( mWindow -> GetGraphPane() );
  425.     
  426.     return mDoc;
  427. }
  428.  
  429. // ---------------------------------------------------------------------------
  430. //        • ChooseDocument
  431. //
  432. //          Called by:    LDocApplication::ObeyCommand
  433. // ---------------------------------------------------------------------------
  434. //    Prompt the user to select a graph file to open
  435.  
  436. void
  437. CGraphGAApp::ChooseDocument()
  438. {
  439.     StandardFileReply    macFileReply;
  440.     SFTypeList            typeList;
  441.     
  442.     UDesktop::Deactivate();
  443.     typeList[0] = FileType_GraphGA;
  444.     ::StandardGetFile( nil, 1, typeList, &macFileReply);
  445.     UDesktop::Activate();
  446.     if (macFileReply.sfGood) {
  447.         OpenDocument( &macFileReply.sfFile);
  448.     }
  449. }
  450.  
  451. // ---------------------------------------------------------------------------
  452. //        • AskNewGraphSize    (PRIVATE)
  453. //
  454. //          Called by:    CGraphGAApp::ObeyCommand
  455. // ---------------------------------------------------------------------------
  456.  
  457. Boolean
  458. CGraphGAApp::AskNewGraphSize()
  459. {
  460.     StDialogHandler        theHandler( WIND_NewGraph, this);
  461.     LWindow                *theDialog = theHandler.GetDialog();
  462.     Int32                theNodeQty, theEdgeQty, theEdgeMax;
  463.     
  464.     LGAEditField *theNodes = (LGAEditField*) theDialog->FindPaneByID( edit_Nodes );
  465.     theNodes  -> SetValue( mNewGraphNodes );
  466.     theNodes  -> SelectAll();
  467.     theDialog -> SetLatentSub( theNodes );
  468.         
  469.     LGAEditField *theEdges = (LGAEditField*) theDialog->FindPaneByID( edit_Edges );
  470.     theEdges  -> SetValue( mNewGraphEdges );
  471.     
  472.     theDialog->Show();
  473.     
  474.     while ( true ) {                    // Let DialogHandler process events
  475.         MessageT    hitMessage = theHandler.DoDialog();
  476.         
  477.         if ( hitMessage == msg_Cancel ) {
  478.             return false;
  479.             
  480.         } else if ( hitMessage == msg_OK ) {
  481.             theNodeQty = theNodes -> GetValue();
  482.             theEdgeQty = theEdges -> GetValue();
  483.  
  484.             // The maximum number of edges depends on the quantity of nodes.
  485.             theEdgeMax = ( theNodeQty % 2L == 0L ) ? 
  486.                          theNodeQty * ((theNodeQty / 2) - 1) + (theNodeQty / 2) :
  487.                          theNodeQty * (theNodeQty / 2);
  488.  
  489.             if ( theNodeQty < 1 ) {
  490.                 UDesktop::Deactivate();
  491.                 ::StopAlert( ALRT_TooFewNodes, nil );
  492.                 UDesktop::Activate();
  493.             } else if ( theEdgeQty > theEdgeMax ) {
  494.                 LStr255    theParam0( theNodeQty );
  495.                 LStr255 theParam1( theEdgeMax );
  496.                 UDesktop::Deactivate();
  497.                 ::ParamText( theParam0, theParam1, "\p", "\p");
  498.                 ::StopAlert( ALRT_TooManyEdges, nil );
  499.                 UDesktop::Activate();
  500.             } else if ( GridSizeOK( mGeneral.sizeGrid, theNodeQty )) {
  501.                 mNewGraphNodes = theNodeQty;
  502.                 mNewGraphEdges = theEdgeQty;
  503.                 break;
  504.             }  
  505.         }
  506.     }
  507.     return true;
  508. }
  509.  
  510. // ---------------------------------------------------------------------------
  511. //        • SetProbsFromDialog    (PRIVATE)
  512. //
  513. //          Called by:    CGraphGAApp::ObeyCommand
  514. // ---------------------------------------------------------------------------
  515.  
  516. void
  517. CGraphGAApp::SetProbsFromDialog( 
  518.     SLGADialogResponse *inResponse )
  519. {
  520.     ((CProbDialog *) inResponse -> dialogBox) 
  521.         -> GetValues( mCrossoverProb, mMutationProb );
  522.         
  523.     delete inResponse -> dialogBox;
  524. }
  525.  
  526. // ---------------------------------------------------------------------------
  527. //        • SetSelFromDialog
  528. //
  529. //          Called by:    CGraphGAApp::ObeyCommand
  530. //                        CGraphGADoc::ObeyCommand
  531. // ---------------------------------------------------------------------------
  532.  
  533. void
  534. CGraphGAApp::SetSelFromDialog( 
  535.     SLGADialogResponse *inResponse )
  536. {
  537.     ((CSelectionDialog *) inResponse -> dialogBox) 
  538.         -> GetValues( mSelection );
  539.  
  540.     delete inResponse -> dialogBox;
  541. }
  542.  
  543. // ---------------------------------------------------------------------------
  544. //        • SetTerFromDialog    (PRIVATE)
  545. //
  546. //          Called by:    CGraphGAApp::ObeyCommand
  547. // ---------------------------------------------------------------------------
  548.  
  549. void
  550. CGraphGAApp::SetTerFromDialog( 
  551.     SLGADialogResponse *inResponse )
  552. {
  553.     ((CTerminationDialog *) inResponse -> dialogBox) 
  554.         -> GetValues( mTermination );
  555.  
  556.     delete inResponse -> dialogBox;
  557. }
  558.  
  559. // ---------------------------------------------------------------------------
  560. //        • SetEvalFromDialog        (PRIVATE)
  561. //
  562. //          Called by:    CGraphGAApp::ObeyCommand
  563. // ---------------------------------------------------------------------------
  564.  
  565. void
  566. CGraphGAApp::SetEvalFromDialog( 
  567.     SLGADialogResponse *inResponse )
  568. {
  569.     ((CEvalDialog *) inResponse -> dialogBox) 
  570.         -> GetValues( mEvaluation );
  571.         
  572.     CFitness::SetEvalStruct( &mEvaluation );
  573.  
  574.     delete inResponse -> dialogBox;
  575. }
  576.  
  577. // ---------------------------------------------------------------------------
  578. //        • SetGeneralFromDialog
  579. //
  580. //          Called by:    CGraphGAApp::ObeyCommand
  581. //                     /*    CGraphGADoc::ObeyCommand */
  582. // ---------------------------------------------------------------------------
  583.  
  584. //Boolean
  585. void
  586. CGraphGAApp::SetGeneralFromDialog( 
  587.     SLGADialogResponse *inResponse,
  588.     Int16        /*    inNodes */ )
  589. {
  590. //    Int16    theOldGridSize = mGeneral.sizeGrid;
  591. //    Int16    theOldPopSize = mGeneral.sizePop;
  592.     
  593.     ((CGeneralDialog *) inResponse -> dialogBox) 
  594.         -> GetValues( mGeneral );
  595.  
  596.     delete inResponse -> dialogBox;
  597. /*    
  598.     if (! inNodes )
  599.         return false;
  600.     else {
  601.         if ( inNodes > ( mGeneral.sizeGrid * mGeneral.sizeGrid - 1 )) {
  602.             UDesktop::Deactivate();
  603.             ::StopAlert( ALRT_TooSmallGrid, nil );
  604.             UDesktop::Activate();
  605.             mGeneral.sizeGrid = theOldGridSize;
  606.         }
  607.         
  608.         // The value we return reports whether the population should
  609.         // be reinitialized because either the size of the population
  610.         // or the grid has changed...
  611.  
  612.         if ( mGeneral.sizeGrid == theOldGridSize &&
  613.              mGeneral.sizePop == theOldPopSize )
  614.              return false;
  615.         else
  616.             return true;
  617.     }
  618. */
  619. }
  620.  
  621. // ---------------------------------------------------------------------------
  622. //        • EventSuspend    (PRIVATE, OVERRIDE)
  623. //
  624. //          Called by:    LEventDispatcher::EventOS
  625. // ---------------------------------------------------------------------------
  626. //    Respond to a Suspend event
  627.  
  628. void
  629. CGraphGAApp::EventSuspend(
  630.     const EventRecord& inMacEvent )
  631. {
  632.     GetTarget() -> ObeyCommand( cmd_IterSuspend, nil );
  633.     
  634.     LEventDispatcher::EventSuspend( inMacEvent ); // Call normal behaviour !!
  635. }
  636.  
  637. // ---------------------------------------------------------------------------
  638. //        • EventResume    (PRIVATE, OVERRIDE)
  639. //
  640. //          Called by:    LEventDispatcher::EventOS
  641. // ---------------------------------------------------------------------------
  642. //    Respond to a Resume event
  643.  
  644. void
  645. CGraphGAApp::EventResume(
  646.     const EventRecord& inMacEvent )
  647. {
  648.     LEventDispatcher::EventResume( inMacEvent ); // Call normal behaviour !!
  649.  
  650.     GetTarget() -> ObeyCommand( cmd_IterResume, nil );
  651. }
  652.  
  653. // ---------------------------------------------------------------------------
  654. //        • SetDefaults    (PRIVATE)
  655. //
  656. //          Called by:    CGraphGAApp::CGraphGAApp
  657. // ---------------------------------------------------------------------------
  658.  
  659. void
  660. CGraphGAApp::SetDefaults()
  661. {
  662.     mGeneral.sizeGrid            = DEFAULT_GRID_SIZE;
  663.     mGeneral.sizePop            = DEFAULT_POP_SIZE;
  664.     mGeneral.spendTime            = DEFAULT_SPEND_TIME;
  665.     
  666.     mEvaluation.crossingsRule    = DEFAULT_CROSSINGS_RULE;
  667.     mEvaluation.multip1            = DEFAULT_MULTIP_1;
  668.     mEvaluation.multip2            = DEFAULT_MULTIP_2;
  669.     mEvaluation.multip3            = DEFAULT_MULTIP_3;
  670.     mEvaluation.multip4            = DEFAULT_MULTIP_4;
  671.     mEvaluation.multip5            = DEFAULT_MULTIP_5;
  672.     mEvaluation.multip6            = DEFAULT_MULTIP_6;
  673.     mEvaluation.multip7            = DEFAULT_MULTIP_7;
  674.     
  675.     CFitness::SetEvalStruct( &mEvaluation );
  676.     
  677.     mNewGraphNodes                = DEFAULT_NEW_GRAPH_NODES;
  678.     mNewGraphEdges                = DEFAULT_NEW_GRAPH_EDGES;
  679.     
  680.     mCrossoverProb                = DEFAULT_CROSSOVER_PROB;
  681.     mMutationProb                = DEFAULT_MUTATION_PROB;
  682.     
  683.     mSelection.step                = DEFAULT_SELECTION_STEP;
  684.     mSelection.min                = DEFAULT_SELECTION_MIN;
  685.     mSelection.autom            = DEFAULT_SELECTION_AUTOM;
  686.     mSelection.elitism            = DEFAULT_ELITISM;
  687.     
  688.     mTermination.maxGenTotal            = DEFAULT_MAX_GEN_TOTAL;
  689.     mTermination.maxGenNoChange            = DEFAULT_MAX_GEN_NO_CHANGE;
  690.     mTermination.maxTimeTotal            = DEFAULT_MAX_TIME_TOTAL;
  691.     mTermination.maxTimeNoChange        = DEFAULT_MAX_TIME_NO_CHANGE;
  692.     mTermination.stopMaxGenTotal        = false;
  693.     mTermination.stopMaxGenNoChange        = false;
  694.     mTermination.stopMaxTimeTotal        = false;
  695.     mTermination.stopMaxTimeNoChange    = false;
  696.     mTermination.stopNoCrossings        = false;
  697. }
  698.  
  699. // ---------------------------------------------------------------------------
  700. //        • RegisterClasses    (PRIVATE)
  701. //
  702. //          Called by:    CGraphGAApp::CGraphGAApp
  703. // ---------------------------------------------------------------------------
  704.  
  705. void
  706. CGraphGAApp::RegisterClasses()
  707. {
  708.     // Register functions to create core PowerPlant classes
  709.  
  710.     RegisterClass_( LCaption    );
  711.     RegisterClass_( LPane        );
  712.     RegisterClass_( LPicture    );
  713.     RegisterClass_( LRadioGroup    );
  714.     RegisterClass_( LTabGroup    );
  715.     RegisterClass_( LView        );
  716.     RegisterClass_( LWindow        );
  717.  
  718.     RegisterClass_( CAGASlider    );
  719.     
  720.     RegisterClass_( CGraphPane            );
  721.     RegisterClass_( CGraphWindow        );
  722.     RegisterClass_( CProbDialog            );
  723.     RegisterClass_( CSelectionDialog    );
  724.     RegisterClass_( CTerminationDialog    );
  725.     RegisterClass_( CGeneralDialog        );
  726.     RegisterClass_( CEvalDialog            );
  727.     RegisterClass_( CMyCaption            );
  728.                                 
  729.     // • APPLE GRAYSCALE APPEARANCE CONTROLS, PANES, VIEWS, and WINDOWS
  730.     //    •• CONTROLS
  731.     
  732.     RegisterClass_( LGAPushButton    );
  733.     RegisterClass_( LGARadioButton    );
  734.     RegisterClass_( LGACheckbox        );
  735.  
  736.     // •• PANES & VIEWS
  737.     
  738.     RegisterClass_( LGAPrimaryBox    );
  739.     RegisterClass_( LGAPrimaryGroup    );
  740.     RegisterClass_( LGASeparator    );
  741.     RegisterClass_( LGAEditField    );
  742.     RegisterClass_( LGABox            );                                
  743.                                 
  744.     // •• WINDOWS
  745.  
  746.     RegisterClass_( LGADialogBox    );                                
  747.  
  748.  
  749.     // --- Sort table for faster access
  750.     
  751.     TArray<SClassTableEntry> *classTable = URegistrar::GetClassTable();
  752.             
  753.     classTable -> Sort();                                    
  754. }
  755.